<?php
namespace Helpers;

use Phalcon\Di;
use Phalcon\Session\Adapter\Files as SessionAdapter;

class Session
{
    /**
     * @var SessionAdapter
     */
    public static $session = false;

    public static function init()
    {
        if (!self::$session) {
            self::$session = Di::getDefault()->get('session');
        }
        return self::$session;
    }

    public static function get($index, $defaultValue = null)
    {
        return self::init()->get($index, $defaultValue);
    }

    public static function set($index, $value)
    {
        self::init()->set($index, $value);
        return self::init()->has($index);
    }

    public static function has($index)
    {
        return self::init()->has($index);
    }

    public static function remove($index)
    {
        return self::init()->remove($index);
    }

    public static function destroy($removeData = false)
    {
        return self::init()->destroy($removeData);
    }

}